//
//  HXExpandViewController.m
//  爱鲜蜂
//
//  Created by 建国 on 16/5/13.
//  Copyright © 2016年 建国. All rights reserved.
//

#import "HXExpandViewController.h"

@interface HXExpandViewController ()
@property (weak, nonatomic)  UIScrollView *expandView ;

@property (nonatomic,assign) CGFloat contentY ;

@end

@implementation HXExpandViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupScrollView];
    self.view.backgroundColor = HXColor(229, 229, 229);
}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    UIBarButtonItem *btnItem = [[UIBarButtonItem alloc]initWithTitle:@"分享 " style:(UIBarButtonItemStylePlain) target:self action:@selector(share)];
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
    dict[NSFontAttributeName] = [UIFont systemFontOfSize:16];
    [btnItem setTitleTextAttributes:dict forState:(UIControlStateNormal)];
    self.navigationController.navigationBar.tintColor = [UIColor grayColor];
    [self.navigationItem setRightBarButtonItem:btnItem];
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"grey1"] forBarMetrics:(UIBarMetricsDefault)];
    [self setTitle:@"没洗猪大肠"];
}
//  添加不同类型的View
-(void)setupScrollView{
    UIScrollView *scrollView= [[UIScrollView alloc]initWithFrame:self.view.bounds];
    self.expandView = scrollView ;
    [self.view insertSubview:scrollView atIndex:0 ];
    [self setupImageView];
    scrollView.contentSize = CGSizeMake(0, 1524);
    scrollView.contentInset = UIEdgeInsetsMake(0, 0, 50, 0);
    [self setupPriceView:@"大美小龙虾" price:@"$98"];
    [self setupDefiniteInformationViewIsDiscount:YES];
    [self setupPromptView];
    [self setupLongImage];
}
//   产品照片
-(void)setupImageView{
    UIImageView *imageV = [[UIImageView alloc]init];
    imageV.frame = CGRectMake(0, 0, SCREEN_WIDTH, 349);
    imageV.image = [UIImage imageNamed:@"1"];
    [self.expandView addSubview:imageV];
}
//    产品名及价格label
-(void)setupPriceView :(NSString *)productName price:(NSString*)price{
    UIView *priceView = [[UIView alloc]initWithFrame:CGRectMake(0, 350, SCREEN_WIDTH, 79)];
    UILabel *nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 17, SCREEN_WIDTH, 30)];
    nameLabel.text = productName ;
    [priceView addSubview:nameLabel];

    UILabel *priceLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 57 , SCREEN_WIDTH, 10)];
    priceLabel.text = price;
    priceLabel.textColor = [UIColor redColor];
    priceLabel.font = [UIFont systemFontOfSize:14];
    [priceView addSubview:priceLabel];
    priceView.backgroundColor = [UIColor whiteColor];
    [self.expandView addSubview:priceView];
}
//    产品具体信息

-(void)setupDefiniteInformationViewIsDiscount :(BOOL)isDiscount {
 
    CGRect brandF = CGRectMake(0, 430, SCREEN_WIDTH, 49);
    [self setupIntroduceView:@"品    牌" content:@"大厨建国" frame:brandF];
    
    CGRect standerdF = CGRectMake(0, 480 , SCREEN_WIDTH, 49);
    [self setupIntroduceView:@"产品规格" content:@"1.5kg" frame:standerdF ];
 
    CGRect detailF = CGRectMake(0, 530, SCREEN_WIDTH, 49);
    [self setupIntroduceView:@"图文详情" content:@"" frame:detailF];
//    判断如果是促销则添加指定样式,
//    if (isDiscount) {
//        
//    }
}
//    提示信息
-(void)setupPromptView{
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 580, SCREEN_WIDTH, 79)];
    UILabel *promptLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 2, 200, 30)];
    promptLabel.text = @"温馨提示";
    [view addSubview:promptLabel];
    
    UILabel *detailLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 30, SCREEN_WIDTH, 40)];
    detailLabel.text = @"商品签收后,有问题请再24小时后内练习客服\n4008484并将商品包装保留好";
    detailLabel.numberOfLines = 0 ;
    detailLabel.font = [UIFont systemFontOfSize:14];
    detailLabel.textColor = [UIColor redColor];
    view.backgroundColor = [UIColor whiteColor];
    [view addSubview:detailLabel];
    [self.expandView addSubview:view];
}

//    尾部长图
-(void)setupLongImage{
    
    UIImageView *longImageV = [[UIImageView alloc]init];
    longImageV.frame= CGRectMake(0, 660, SCREEN_WIDTH, 800);
    longImageV.image = [UIImage imageNamed:@"guide_40_1"] ;
    [self.expandView addSubview:longImageV];
}

//    具体信息样式
-(void)setupIntroduceView :(NSString*)typeName content:(NSString*)content frame :(CGRect)fream {
    
    UIView *view = [[UIView alloc]initWithFrame:fream];
    view.backgroundColor = HXColor(240, 240, 240);
    UILabel *typeLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 70, 50)];
    typeLabel.font = [UIFont systemFontOfSize:14];
    typeLabel.textColor = [UIColor grayColor];
    typeLabel.textAlignment = NSTextAlignmentCenter ;
    typeLabel.text = typeName ;
    UILabel *contentLabel = [[UILabel alloc]initWithFrame:CGRectMake(100, 0, 200, 50)];
    contentLabel.text = content ;
    contentLabel.font = [UIFont systemFontOfSize:15];

    [view addSubview: typeLabel];
    [view addSubview:contentLabel];
    [self.expandView addSubview:view];
}


-(void)share{
    
}


@end
